package com.jdls.aop;

import jdk.internal.cmm.SystemResourcePressureImpl;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * @author 嘉德罗斯
 * @date 2021/9/13
 */
@Component
@Aspect
public class StudentAop {
    @Pointcut("execution(void com.jdls.pojo.Student.*())")
    public void pc(){}
    @Around("pc()")
    public void method(ProceedingJoinPoint pjp) throws Throwable {
        Signature signature = pjp.getSignature();
        Class declaringType = signature.getDeclaringType();
        String name = signature.getName();
        long op= System.currentTimeMillis();
        for (int i = 0; i < 10000; i++) {
            pjp.proceed();
        }
        long ed = System.currentTimeMillis();
        System.out.println("万次运行时间为："+declaringType+"."+name+"--->"+(ed-op)+"ms");
    }
}
